package com.itheima.d6_object_stream;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;

/*
  目标：掌握对象字节输出流的使用：序列化对象。
 */
public class Test1ObjectOutputStream {
    public static void main(String[] args) throws Exception {
        //创建对象
        FileOutputStream fos = new FileOutputStream("object.txt");
        ObjectOutputStream oos = new ObjectOutputStream(fos);
        //写对象
        User user = new User("萧炎","天才少年","佛怒火链",18);
        User user1 = new User("唐三","海神","黄金十三戟",28);
        ArrayList<User> list = new ArrayList<>();
        list.add(user);
        list.add(user1);
        oos.writeObject(list);
//        oos.writeObject(user1);

        //释放对象
        oos.close();
    }
}
